package com.ruoyi.cmemetal.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.cmecomon.service.IZxOrderPostmanService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.cmemetal.domain.ZxDataPreprocess;
import com.ruoyi.cmemetal.service.IZxDataPreprocessService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * DataPreprocessController
 * 
 * @author zhangxu
 * @date 2021-12-28
 */
@RestController
@RequestMapping("/DataPreprocess/preprocess")
public class ZxDataPreprocessController extends BaseController
{
    @Autowired
    private IZxDataPreprocessService zxDataPreprocessService;

    @Autowired
    private IZxOrderPostmanService zxOrderPostmanService;

    /**
     * 查询DataPreprocess列表
     */
    @PreAuthorize("@ss.hasPermi('DataPreprocess:preprocess:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZxDataPreprocess zxDataPreprocess)
    {
        startPage();
        List<ZxDataPreprocess> list = zxDataPreprocessService.selectZxDataPreprocessList(zxDataPreprocess);
        return getDataTable(list);
    }

    /**
     * 导出DataPreprocess列表
     */
    @PreAuthorize("@ss.hasPermi('DataPreprocess:preprocess:export')")
    @Log(title = "DataPreprocess", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZxDataPreprocess zxDataPreprocess)
    {
        List<ZxDataPreprocess> list = zxDataPreprocessService.selectZxDataPreprocessList(zxDataPreprocess);
        ExcelUtil<ZxDataPreprocess> util = new ExcelUtil<ZxDataPreprocess>(ZxDataPreprocess.class);
        util.exportExcel(response, list, "DataPreprocess数据");
    }

    /**
     * 获取DataPreprocess详细信息
     */
    @PreAuthorize("@ss.hasPermi('DataPreprocess:preprocess:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        ZxDataPreprocess zxDataPreprocess = zxDataPreprocessService.selectZxDataPreprocessById(id);
        AjaxResult success = AjaxResult.success(zxDataPreprocess);
        success.put("orderPostmen",zxOrderPostmanService.selectOrderPostmenDictByOrderId(zxDataPreprocess.getOrderId()));

        return success;
    }

    /**
     * 新增DataPreprocess
     */
    @PreAuthorize("@ss.hasPermi('DataPreprocess:preprocess:add')")
    @Log(title = "DataPreprocess", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZxDataPreprocess zxDataPreprocess)
    {
        return toAjax(zxDataPreprocessService.insertZxDataPreprocess(zxDataPreprocess));
    }

    /**
     * 修改DataPreprocess
     */
    @PreAuthorize("@ss.hasPermi('DataPreprocess:preprocess:edit')")
    @Log(title = "DataPreprocess", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZxDataPreprocess zxDataPreprocess)
    {
        return toAjax(zxDataPreprocessService.updateZxDataPreprocess(zxDataPreprocess));
    }

    /**
     * 删除DataPreprocess
     */
    @PreAuthorize("@ss.hasPermi('DataPreprocess:preprocess:remove')")
    @Log(title = "DataPreprocess", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zxDataPreprocessService.deleteZxDataPreprocessByIds(ids));
    }
}
